package demo1;
class Animal {
    public int age;
    public String name;

    public Animal(int age, String name) {
        this.age = age;
        this.name = name;
    }

    public void eat() {
        System.out.println("吃饭！");
    }
}

interface IFlying {
    void fly();
}
interface ISwimming {
    void swim();
}
interface IRunning {
    void run();
}
class Dog extends Animal implements ISwimming, IRunning {
    public Dog(int age, String name) {
        super(age, name);
    }
    @Override
    public void swim() {
        System.out.println(name + "游泳");
    }
    public void run() {
        System.out.println(name + "跑步");
    }
}
class Duck extends Animal implements ISwimming, IRunning, IFlying { //解决了多继承的问题
    public Duck(int age, String name) {
        super(age, name);
    }
    @Override
    public void swim() {
        System.out.println(name + "游泳");
    }
    public void run() {
        System.out.println(name + "跑步");
    }
    public void fly() {
        System.out.println(name + "飞");
    }

}

interface D1 {
    void func1();
}
interface D2 {
    void func2();
}
interface D3 extends D1, D2 { //接口与接口间用extends
    void func3();
}
class D4 implements D3 {

    @Override
    public void func1() {

    }

    @Override
    public void func2() {

    }

    @Override
    public void func3() {

    }
}
public class Test4 {
    public static void main1(String[] args) {
        Dog dog = new Dog(10, "bitch");
    }

    public static void walk(IRunning iRunning) {
        iRunning.run();
    }
    public static void main(String[] args) {
        walk(new Dog(10, "常威"));
        walk(new Duck(10, "bitch"));
    }
}
